<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once BASEPATH.'core/Controller.php';
class Admin_Controller extends CI_Controller {
	protected $base_url,$platform,$admin_info,$data;
	protected $platform_list	=	array('1'=>'要点啥微盘');
	protected $pagesize	=	"30";
	public function __construct(){  
        parent::__construct();
		$this->load->config('config');
		$this->platform	=	$this->config->item('platform');

		$this->load->library('Admin_Class');
        $this->admin_info	=	$this->admin_class->isLogin($this->platform,true);
		$this->base_url	=	base_url();
		if(!$this->admin_info){
    		redirect($this->base_url.'login');
    	}

		$this->load->library('Menu_Class');//加载菜单
		$sid	=	$this->input->get('sid');
		$this->data['menu']	=	$this->menu_class->menu($this->admin_info,$sid);
		$this->data['admin']=	$this->admin_info;
		$this->data['sid']	=	$sid;
		$this->data['platform']			=	$this->platform;
		$this->data['platform_list']	=	$this->platform_list;
		$this->data['myprefix_open_withdrawal']	=	1;
		//echo "<pre>";var_dump($this->data['menu']);die;
    }

	public function get_url($except=array()){
		$url_arr	= explode("?",$_SERVER['REQUEST_URI']);
		$url		= $url_arr[0]."?";
		if(!empty($url_arr[1])){
			$query_arr	=	explode("&",$url_arr[1]);
			foreach ($query_arr as $str){
				list($key,$value) = explode("=",$str);
				if(!in_array($key,$except)){
					$parr[$key]	=	trim($value);
				}
			}
		}

		if(!empty($parr)){
			$url	.=	http_build_query($parr);
		}
	
		return $url;
	}

    public function alertMsg($msg,$url=''){
		if(empty($url)){
			echo <<<EOD
            <script>
				alert('{$msg}');
				window.history.back(-1);
            </script>
EOD;
            die;
		}else{
			echo <<<EOD
            <script>
				alert('{$msg}');
				window.location.href='{$url}';
            </script>
EOD;
            die;
		}
    }
}
?>